import React, { Component } from 'react'
import {
    Form, TreeSelect, message
} from 'antd';
import { connect } from 'dva';


const FormItem = Form.Item;

@connect(({ add }) => ({
    add: add
}))
class RightBanner extends React.PureComponent{
    constructor(props) {
        super(props);
        this.state = {
            radioValue:1
        }
        this.getFieldsValue = this.getFieldsValue.bind(this)
    }
    componentDidMount(){
        this.props.onRef(this)
    }

        /**
     * 设置默认版面
     */
    setBanMianFields = (data)=>{
        this.props.form.setFieldsValue(data)
    }
    /**
     * 获取表单的值
     */
    getFieldsValueTab=()=>{
        let data = this.props.form.getFieldsValue()
        return data
    }
    getFieldsValue=()=>{
        let data = this.props.form.getFieldsValue()
        this.props.form.validateFields()
        if(data.plate_id&&data.plate_id){
            return data
        }
    }
    /**
     * 重置表单
     */
    resetFields=()=>{
        this.props.form.resetFields()
    }
     /**
     * 设置表单值
     */
    setFields = (data) => {
        this.props.form.setFieldsValue(data)
    }
    render() {
        const { getFieldDecorator } = this.props.form;
        const { plateList } = this.props.add
        const formItemLayout = {
        labelCol: {
            xs: { span: 24 },
            sm: { span: 7 },
        },
        wrapperCol: {
            xs: { span: 24 },
            sm: { span: 17 },
        },
        };
        return (
            <div className="righttwo">
                <h3>基本信息</h3>
                <Form >
                    <FormItem
                    {...formItemLayout}
                    label="版面/样式"
                    >
                    {getFieldDecorator('plate_id', {
                        rules: [{
                        required: true, message: '请选择版面/样式',
                        }],
                    })(
                        <TreeSelect
                            size="small"
                            dropdownStyle={{ maxHeight: 400 }}
                            dropdownMatchSelectWidth
                            placeholder="请选择版面/样式"
                            treeData={plateList}
                            treeDefaultExpandAll
                            allowClear
                        />
                    )}
                    </FormItem>
                </Form>
            </div>
        )
    }
}

const RightBanners = Form.create()(RightBanner);
export default RightBanners;
